package com.upic.serviceImpl;

import com.upic.po.Examination;
import com.upic.repository.ExaminationRepository;
import com.upic.service.ExaminationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author YeTian
 * @date 2018/2/7/007
 */
@Service("examinationService")
public class ExaminationServiceImpl implements ExaminationService {

    @Autowired
    private ExaminationRepository examinationRepository;

    @Override
    public Examination saveExamination(Examination examination) {
        return examinationRepository.save(examination);
    }

    @Override
    public String deleteExamination(long examinationId) {
        examinationRepository.delete(examinationId);
        return "SUCCESS";
    }

    @Override
    public Page<Examination> searchExamination(Pageable pageable) {
        return examinationRepository.findAll(pageable);
    }

    @Override
    public List<Examination> searchExamination() {
        return examinationRepository.findAll();
    }

    @Override
    public Examination findOne(long examinationId) {
        return examinationRepository.findOne(examinationId);
    }

    @Override
    public Examination updateExamination(Examination examination) {
        return examinationRepository.saveAndFlush(examination);
    }
}
